{% include "spent/shortcuts.html" %}

<div id="graphs" style="text-align: left; margin-top: 5px;">
   {{ pieChart|safe }}
</div>

{% if spents %}
    <form action="/cassaco/spent/delete" method="POST">
    <table width=100% >
    <thead>
        <th></th>
        <th>Description</th>
        <th>Type</th>
        <th>Sub-type</th>
        <th>Date</th>
        <th>Mode</th>
        <th>Value</th>
    </thead>
    <tr>
        <td colspan="6">
            Select: 
            <a style="cursor: pointer" onclick="
                $('input[@class=checkspent]').each(function(){  
                    this.checked = true;
                }); 
                ">
                all
            </a>
            <a style="cursor: pointer" onclick="
                $('input[@class=checkspent]').each(function(){  
                    this.checked = false;
                }); 
                ">
                , none
            </a>
            <input type="submit" value="Delete"/>
        </td>
    </tr>
    {% for spent in spents %}
        <tr style="cursor: pointer;" onMouseOver="this.className='highlight';"
            onMouseOut="this.className='normal';">
            <td>
                <input class="checkspent" name="id" type="checkbox" value="{{ spent.id }}"/>
            </td>
            <td class="{{ spent.id }}">{{ spent.description }}</td>
            <td class="{{ spent.id }}">{{ spent.category }}</td>
            <td class="{{ spent.id }}">{{ spent.subcategory }}</td>
            <td class="{{ spent.id }}">{{ spent.date }}</td>
            <td class="{{ spent.id }}">{{ spent.mode }}</td>
            <td class="{{ spent.id }}">{{ spent.value }}</td>
        </tr>
        <script>
        $(".{{ spent.id }}").click(
                function () {
                	if ($("#add").is(":hidden")) {
			          $("#add").slideDown("slow");
			        }
                    $("#add").load("/cassaco/spent/edit/{{ spent.id }}");
                }
        );
        </script>
    {% endfor %}
    </table>
    </form>
    {% include "spent/paginator.html" %}
{% endif %}